/**
 * 
 */
package edu.umd.clip.lm.ngram;

public class Bigram extends Ngram{
	long w1;
	
	Bigram(long[] context, long future) {
		this(context[0], future);
	}
	
	public Bigram(long w1, long future) {
		super(future);
		this.w1 = w1;
	}

	/* (non-Javadoc)
	 * @see edu.umd.clip.lm.tools.PruneTrainingData.Ngram#getContext()
	 */
	@Override
	public long[] getContext() {
		return new long[] {w1};
	}

	/* (non-Javadoc)
	 * @see edu.umd.clip.lm.tools.PruneTrainingData.Ngram#getOrder()
	 */
	@Override
	public int getOrder() {
		return 2;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + (int) (w1 ^ (w1 >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (!(obj instanceof Bigram))
			return false;
		Bigram other = (Bigram) obj;
		if (w1 != other.w1)
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see edu.umd.clip.lm.ngram.Ngram#getLowerOrderNgram()
	 */
	@Override
	public Ngram getLowerOrderNgram() {
		return new Unigram(future);
	}

}